{include file="public/header" /}
<link rel="stylesheet" type="text/css" href="/static/admin/webupload/webuploader.css">
<link rel="stylesheet" type="text/css" href="/static/admin/webupload/style.css">
<style>
    .file-item{float: left; position: relative; width: 110px;height: 110px; margin: 0 20px 20px 0; padding: 4px;}
    .file-item .info{overflow: hidden;}
    .uploader-list{width: 100%; overflow: hidden;}
</style>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>编辑分值标签</h5>
                    <div class="ibox-tools">
                        <div class="ibox-tools">
                            <a class="collapse-link" style="color: lightskyblue" href="{:url('index')}?page={$page}&no_ajax=1">
                                上一页<i class="fa fa-chevron-up"></i>
                            </a>
                        </div>
                    </div>
                </div>
                <div class="ibox-content">
                    <form class="form-horizontal" name="optionEdit" id="optionEdit" method="post" action="{:url('optionEdit')}">
                        <input type="hidden" name="id" value="{$option['id']}">

                        <div class="form-group">
                            <label class="col-sm-3 control-label">关联题目：</label>
                            <div class="input-group col-sm-4">
                                <select class="form-control m-b chosen-select" name="question_id" id="question_id">
                                    <option value="">==请选择==</option>
                                    {if !empty($question)}
                                    {foreach name="question" item="vo"}
                                    <option value="{$vo.id}" {if condition="$option.question_id eq $vo.id"}selected{/if}>{$vo.name}</option>
                                    {/foreach}
                                    {/if}
                                </select>
                            </div>
                        </div>


                        <div class="hr-line-dashed"></div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label">分类：</label>
                            <div class="input-group col-sm-4">
                                <select class="form-control m-b chosen-select" name="cat_id" id="cat_id">
                                    <option value="">==请选择==</option>
                                    {if !empty($option_cat)}
                                    {foreach name="option_cat" item="vo"}
                                    <option value="{$vo.id}" {if condition="$option.cat_id eq $vo.id"}selected{/if}>{$vo.name}</option>
                                    {/foreach}
                                    {/if}
                                </select>
                            </div>
                        </div>

                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">名称：</label>
                            <div class="input-group col-sm-4">
                                <input id="name" type="text" class="form-control" name="name" value="{$option['name']}">
                            </div>
                        </div>



                        <div class="hr-line-dashed"></div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label">费用：</label>
                            <div class="input-group col-sm-4">
                                <input id="point" type="text" class="form-control" name="point" value="{$option['point']}">
                            </div>
                        </div>


                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">描述：</label>
                            <div class="input-group col-sm-4">
                                <textarea id="remark" type="text" class="form-control" name="remark"  > {$option['remark']}</textarea>

                            </div>
                        </div>


                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">排序：</label>
                            <div class="input-group col-sm-4">
                                <input id="sort" type="text" class="form-control" name="sort" value="{$option['sort']}" >

                            </div>
                        </div>

                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-3">
                                <button class="btn btn-primary" type="submit"><i class="fa fa-save"></i> 保存</button>&nbsp;&nbsp;&nbsp;
                                <a class="btn btn-danger" href="javascript:history.go(-1);"><i class="fa fa-close"></i> 返回</a>
                            </div>
                        </div>
                    </form>
                </div>
            </div>

        </div>
    </div>
</div>
{include file="public/footer" /}
<script type="text/javascript" src="/static/admin/webupload/webuploader.min.js"></script>

<script type="text/javascript">


    //提交
    $(function(){
        $('#optionEdit').ajaxForm({
            beforeSubmit: checkForm,
            success: complete,
            dataType: 'json'
        });



        function checkForm(){

            if( '' == $.trim($('#question_id').val())){
                layer.msg('请关联题目',{icon:2,time:1500,shade: 0.1}, function(index){
                    layer.close(index);
                });
                return false;
            }

            if( '' == $.trim($('#name').val())){
                layer.msg('请输入名称',{icon:2,time:1500,shade: 0.1}, function(index){
                    layer.close(index);
                });
                return false;
            }
        }


        function complete(data){
            if(data.code==1){
                layer.msg(data.msg, {icon: 6,time:1500,shade: 0.1}, function(index){
                    window.location.href="{:url('option/index')}";
                });
            }else{
                layer.msg(data.msg, {icon: 5,time:1500,shade: 0.1});
                return false;
            }
        }
    });



    //IOS开关样式配置
    var elem = document.querySelector('.js-switch');
    var switchery = new Switchery(elem, {
        color: '#1AB394'
    });
    var config = {
        '.chosen-select': {},
    }
    for (var selector in config) {
        $(selector).chosen(config[selector]);
    }

</script>
</body>
</html>